/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package luft27.comm.mavlink;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

/**
 *
 * @author amalikov
 */
public class CommandLong implements MessagePayload {
	public float param1;
	public float param2;
	public float param3;
	public float param4;
	public float param5;
	public float param6;
	public float param7;
	public short command;
	public byte target_system;
	public byte target_component;
	public byte confirmation;

	@Override
	public byte[] get() {
		ByteBuffer bb = ByteBuffer.allocate(256).order(ByteOrder.LITTLE_ENDIAN);
		bb.putFloat(param1);
		bb.putFloat(param2);
		bb.putFloat(param3);
		bb.putFloat(param4);
		bb.putFloat(param5);
		bb.putFloat(param6);
		bb.putFloat(param7);
		bb.putShort(command);
		bb.put(target_system);
		bb.put(target_component);
		bb.put(confirmation);
		return Arrays.copyOf(bb.array(), bb.position());
	}

	@Override
	public void set(byte[] data) {
		ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
		param1 = bb.getFloat();
		param2 = bb.getFloat();
		param3 = bb.getFloat();
		param4 = bb.getFloat();
		param5 = bb.getFloat();
		param6 = bb.getFloat();
		param7 = bb.getFloat();
		command = bb.getShort();
		target_system = bb.get();
		target_component = bb.get();
		confirmation = bb.get();
	}
}
